# 定义商品信息，包括名称、数量、单价
products = [
    {"name": "金士顿U盘8G", "quantity": 1, "unit_price": 40.00},
    {"name": "胜创16GTF卡", "quantity": 1, "unit_price": 50.00},
    {"name": "读卡器", "quantity": 1, "unit_price": 8.00},
    {"name": "网线2米", "quantity": 1, "unit_price": 5.00},
    {"name": "笔记本", "quantity": 1, "unit_price": 10.00}
]

# 计算每个商品的金额以及总额
total_amount = 0
for product in products:
    product["amount"] = product["quantity"] * product["unit_price"]
    total_amount += product["amount"]

# 计算8折后金额
discount = 0.8
discounted_total = total_amount * discount
# 计算折扣金额
discount_amount = total_amount - discounted_total

# 打印购物小票表头
print("-" * 40)
print("单号: DH202311010001")
print("时间: 2023-11-01 20:56:15")
print("-" * 40)
print(f"{'名称':<15}{'数量':<8}{'单价':<8}{'金额':<8}")

# 打印每个商品的信息
for product in products:
    print(f"{product['name']:<15}{product['quantity']:<8}{product['unit_price']:<8.2f}{product['amount']:<8.2f}")

print("-" * 40)
print(f"总数: {len(products)}{'总额:':>20}{total_amount:.2f}")
print(f"折扣率: {discount * 10:.0f}折")
print(f"折扣金额: {discount_amount:.2f}")
print(f"折后总额: {discounted_total:.2f}")
print(f"实收: {discounted_total:.2f}{'找零:':>20}0.00")
print("收银: 管理员")
print("-" * 40)